package com.ridanlabs.professorwebsite.security;

import java.util.Collection;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;

import com.ridanlabs.professorwebsite.models.UserProfile;

@SuppressWarnings("serial")
public class UserProfileAuthentication implements Authentication {
	private final UserProfile principal;
	private final Object details;
	private boolean authenticated;
	
	public UserProfileAuthentication(UserProfile principal, Object details) {
		this.details = details;
		this.principal = principal;
		this.authenticated = true;
	}

	@Override
	public String getName() {
		return principal.getId();
	}

	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return principal.getAuthorities();
	}

	@Override
	public Object getCredentials() {
		throw new UnsupportedOperationException();
	}

	@Override
	public Object getDetails() {
		return null;
	}

	@Override
	public Object getPrincipal() {
		return principal;
	}

	@Override
	public boolean isAuthenticated() {
		return authenticated;
	}

	@Override
	public void setAuthenticated(boolean authenticated) throws IllegalArgumentException {
		this.authenticated = authenticated;
	}
	
    @Override
    public String toString() {
        return "UserProfileAuthentication{" +
                "principal=" + principal +
                ", details=" + details +
                ", authenticated=" + authenticated +
                '}';
    }

}
